<extend name="Base/base" />
<block name='head'>
    <link rel="stylesheet" href="/Public/Admin/css/personal.css"/>
</block>
<block name="content"> 
    <section class="layui-larry-box">
        <div class="larry-personal">
            <div class="layui-tab inputArea">
                <blockquote class="layui-elem-quote news_search">
                    <div class="layui-inline">
                        <a class="layui-btn layui-btn-normal newsAdd_btn" href="{:U('Index/user')}">返回</a>
                    </div>
                </blockquote>
                
                <!-- 表单项 -->
                <form class="layui-form" action="">
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="c-red">*</span>用户名</label>
                        <div class="layui-input-block">
                            <input type="text" name="user_id" class="layui-input" value="{$info.user_id}" placeholder="请使用姓名全拼(小写)">
                            <span class="errMsg"></span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="c-red">*</span>真实姓名</label>
                        <div class="layui-input-block">
                            <input type="text" name="user_name" class="layui-input" value="{$info.user_name}" placeholder="中文姓名">
                            <span class="errMsg"></span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="c-red">*</span>手机号</label>
                        <div class="layui-input-block">
                            <input type="text" name="mobil_no" class="layui-input" value="{$info.mobil_no}" placeholder="请填写该用户与微信绑定的手机号">
                            <span class="errMsg"></span>
                        </div>
                    </div>

                    <div class="layui-form-item point">
                        <a class="open">
                            <label class="layui-form-label pointer" style="width:200px;text-align: right;padding-right:0">展开用户基本信息</label>
                            <img src="/Public/Admin/images/arrow-down.png" style="margin-top: 10px;">
                        </a>
                    </div>
                    <div class="childCate" style="display:none">
                        <div class="layui-form-item">
                            <label class="layui-form-label">性别</label>
                            <div class="layui-input-block sex">
                                <lable class="input_lable">
                                    <input name="sex" type="radio" id="sex-1" value="1" {$info['sex'] == 1 ? 'checked' :''}>
                                    <label for="sex-1">男</label>
                                </lable>
                                <lable class="input_lable">
                                    <input type="radio" id="sex-2" value="0" name="sex" {$info['sex'] == 0 ? 'checked' :''}>
                                    <label for="sex-2">女</label>
                                </lable>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">生日</label>
                            <div class="layui-input-block">
                                <input type="text" name="birthday" class="layui-input datepickerInput" data-type="0" value="{$info.birthday}">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">邮箱</label>
                            <div class="layui-input-block">
                                <input type="text" name="email" class="layui-input" value="{$info.email}">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="c-red">*</span>主角色</label>
                        <div class="layui-input-block value">
                            <div class="textarea addPriv_1" data-id="1" data-key="user_priv" style="border:1px solid #e6e6e6;height:36px;width:80%;display:inline-block;padding:10px">
                                <span></span>
                                <if condition='$info[user_priv] neq 0'>
                                    <span>
                                        <a>{$info.user_priv|getPrivName}</a><img class='pointer delOperator' data-id='{$info.user_priv}' src='/Public/Index/img/close_red.png' alt='close' width='12'>
                                        <input name='priv_id[]' value='{$info.user_priv}' type='hidden'/>
                                        <input name='priv_name[]' vlaue='{$info.user_priv|getPrivName}' type='hidden' />
                                    </span>
                                </if>
                            </div>
                            <a class="pointer addPriv" data-key="1"><img src="/public/Admin/images/add.png">添加</a>
                            <a class="pointer delData"><img src="/public/Admin/images/del.png">清空</a>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">辅助角色</label>
                        <div class="layui-input-block value">
                            <div class="textarea addPriv_2" data-id="2" data-key="user_priv_other" style="border:1px solid #e6e6e6;height:60px;width:80%;display:inline-block;padding:10px">
                                <span></span>
                                <notempty name="info.others">
                                <foreach name='info.others' item='priv'>
                                    <span>
                                        <a>{$priv|getPrivName}</a><img class='pointer delOperator' data-id='{$priv}' src='/Public/Index/img/close_red.png' alt='close' width='12'>
                                        <input name='user_priv_other[]' value='{$priv}' type='hidden'/>
                                        <input name='priv_name[]' vlaue='{$priv|getPrivName}' type='hidden' />
                                    </span>
                                </foreach>
                                </notempty>
                            </div>
                            <a class="pointer addPriv" data-key="2"><img src="/public/Admin/images/add.png">添加</a>
                            <a class="pointer delData"><img src="/public/Admin/images/del.png">清空</a>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label"><span class="c-red">*</span>部门</label>
                        <div class="layui-input-block">
                            <select name="dept_id" class="layui-input">
                                <foreach name="depts" item="dept">
                                    <option value="{$dept.dept_id}" {$info['dept_id'] == $dept['dept_id'] ? 'selected' : ''}>{$dept.dept_name}</option>
                                </foreach>
                                <option value="0" {$info['dept_id'] == 0 ? 'selected' : ''}>离职</option>
                            </select>
                            <span class="errMsg"></span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户排序</label>
                        <div class="layui-input-block">
                            <input type="text" name="user_no" class="layui-input" value="{$info.user_no}" placeholder="该用户在列表中的排列顺序">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block button">
                            <input type='hidden' name='id' value='{$info.user_id}'>
                            <a class="layui-btn btn-submit ajax-post" data-url="{:U('saveUser')}" data-form="">提交</a>
                            <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                        </div>
                    </div>
                </form>
                <!-- 完 -->
            </div>
        </div>
    </section>
</block>
<block name="script">
    <script type="text/javascript" src="/Public/Admin/js/admin.js"></script>
    <script type="text/javascript">
        $(initUser());
        //检查表单
        $('.ajax-post').on('click', function () {
            var flag = true;
            if ($('input[name="user_id"]').val() == '') {
                var msg = '用户名不能为空！'
                $('input[name="user_id"]').next().text(msg);
                flag = false;
            } else {
                $(this).next().text('');
            }
            if ($('input[name="user_name"]').val() == '') {
                var msg = '真实姓名不能为空！'
                $('input[name="user_name"]').next().text(msg);
                flag = false;
            } else {
                $(this).next().text('');
            }
            if ($('input[name="mobil_no"]').val() == '') {
                var msg = '手机号码不能为空！'
                $('input[name="mobil_no"]').next().text(msg);
                flag = false;
            } else {
                $(this).next().text('');
            }
            if ($('.addPriv_1 span').length == 1) {
                layer.msg('请选择主角色！');
                flag = false;
            }
            if ($('select[name=dept_id]').val() == 0) {
                var msg = '请选择部门！'
                $('select[name="dept_id"]').next().text(msg);
                flag = false;
            } else {
                $(this).next().text('');
            }
            if (flag == false) {
                $(this).removeClass('btn-submit');
            } else {
                $(this).addClass('btn-submit');
            }
        })
    </script>
    <script type="text/javascript" src="/Public/Admin/js/common.js"></script>
    <script type="text/javascript">
        $(dateTime());
    </script>    
</block>


